package com.hnevc.mytrafficdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hnevc.mytrafficdemo.R;
import com.hnevc.mytrafficdemo.entity.AntiTrafficDetail;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by Administrator on 2017/12/24.
 */

public class AntiCarDetailAdapter extends BaseAdapter{
    SimpleDateFormat sdf ;
    Context mContext;
    List<AntiTrafficDetail> mAntiTrafficDetailList;

    public AntiCarDetailAdapter(Context context, List<AntiTrafficDetail> antiTrafficDetailList) {
        mContext = context;
        mAntiTrafficDetailList = antiTrafficDetailList;
        sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    }

    @Override
    public int getCount() {
        return mAntiTrafficDetailList.size();
    }

    @Override
    public Object getItem(int i) {
        return mAntiTrafficDetailList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(mContext).inflate(R.layout.anti_traffic_detail_list_item,null);
        TextView mTvAntiDate = (TextView) view.findViewById(R.id.id_tv_anti_date);
        mTvAntiDate.setText(sdf.format(mAntiTrafficDetailList.get(i).getAntiTime()));

        return view;
    }
}
